package com.browser.devtools;

import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BorderPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DevTools {
    private static final Logger logger = LoggerFactory.getLogger(DevTools.class);
    
    private final BorderPane root;
    private final TabPane toolsPane;
    private final ConsolePanel consolePanel;
    private final NetworkPanel networkPanel;
    private final ElementsPanel elementsPanel;

    public DevTools() {
        this.root = new BorderPane();
        this.toolsPane = new TabPane();
        this.consolePanel = new ConsolePanel();
        this.networkPanel = new NetworkPanel();
        this.elementsPanel = new ElementsPanel();
        
        initializeUI();
    }

    private void initializeUI() {
        // 创建开发者工具标签页
        Tab elementsTab = new Tab("Elements", elementsPanel.getContent());
        Tab consoleTab = new Tab("Console", consolePanel.getContent());
        Tab networkTab = new Tab("Network", networkPanel.getContent());
        
        toolsPane.getTabs().addAll(elementsTab, consoleTab, networkTab);
        root.setCenter(toolsPane);
    }

    public BorderPane getContent() {
        return root;
    }

    public void log(String message) {
        consolePanel.log(message);
    }

    public void error(String message) {
        consolePanel.error(message);
    }

    public void addNetworkRequest(String url, String method, int status) {
        networkPanel.addRequest(url, method, status);
    }
} 